<template>
  <div>
    <div class="warn-top">
      <h4 style="text-align: left; color: #126bff; margin-bottom: 20px">
        一键报警管理
      </h4>
      <!--         :rules="rules" -->
      <el-form
        ref="elForm"
        :model="formData"
        size="medium"
        label-width="120px"
        style="display: flex"
        id="elform"
      >
        <el-form-item label="护卫学校名称：" prop="hwxxmc" style="width: 450px">
          <el-input
            v-model="formData.name"
            placeholder="请输入护卫学校名称"
            clearable
            :style="{ width: '60%' }"
          >
          </el-input>
        </el-form-item>
        <el-form-item label="报警人姓名：" prop="name" style="width: 450px">
          <el-input
            v-model="formData.name"
            placeholder="请输入姓名"
            clearable
            :style="{ width: '60%' }"
          >
          </el-input>
        </el-form-item>
        <el-form-item label="报警时段：" prop="time" style="width: 450px">
          <el-date-picker
            type="daterange"
            v-model="formData.time"
            format="yyyy-MM-dd"
            value-format="yyyy-MM-dd"
            :style="{ width: '60%' }"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            range-separator="至"
            clearable
          ></el-date-picker>
        </el-form-item>
        <el-form-item size="large">
          <el-button
            @click="resetForm()"
            style="color: #126bff; background-color: #e6effa"
            >重置</el-button
          >
          <el-button
            type="primary"
            @click="submitForm(formData)"
            style="color: #ffffff; background-color: #126bff"
            >查询</el-button
          >
        </el-form-item>
      </el-form>
    </div>
    <div class="warn-content" style="width: 100%">
      <el-table
        :data="
          tableData.slice((currentPage - 1) * pageSize, currentPage * pageSize)
        "
        style="width: 100%"
      >
        <el-table-column prop="id" label="序号" width="100"> </el-table-column>
        <el-table-column prop="name" label="姓名"> </el-table-column>
        <el-table-column prop="phone" label="手机号"> </el-table-column>
        <el-table-column prop="address" label="报警位置"> </el-table-column>
        <el-table-column prop="time" label="报警时间"> </el-table-column>
        <el-table-column label="操作">
          <template slot-scope="scope">
            <el-button @click="handleClick(scope.row)" type="text" size="small"
              >详情</el-button
            >
            <!-- <el-button type="text" size="small">编辑</el-button> -->
          </template>
        </el-table-column>
      </el-table>
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="currentPage"
        :page-sizes="[1, 2, 4, 8]"
        :page-size="pageSize"
        layout="total, prev, pager, next, sizes"
        :total="tableData.length"
        style="float: right; margin-top: 20px"
      >
      </el-pagination>
    </div>
    <div>
      <el-dialog
        title="详情"
        :visible.sync="dialogVisible"
        width="60%"
        :before-close="handleClose"
        style="border-radius: 20px"
      >
        <div style="display: flex; text-align: left">
          <div style="margin-right: 20px; box-sizing: border-box">
            <p style="height: 40px; line-height: 40px">
              姓名：{{ detaile.name }}
            </p>
            <p style="height: 40px; line-height: 40px">
              报警位置：{{ detaile.address }}
            </p>
          </div>
          <div>
            <p style="height: 40px; line-height: 40px">
              手机号：{{ detaile.phone }}
            </p>
            <p style="height: 40px; line-height: 40px">
              报警时间：{{ detaile.time }}
            </p>
          </div>
        </div>
      </el-dialog>
    </div>
  </div>
</template>
<script>
export default {
  name: "WARN",
  components: {},
  data() {
    return {
      currentPage4: 4,
      // pages: {
      // 按页数查询数据
      currentPage: 1,
      pageSize: 4,
      // },
      formData: {
        name: "",
        time: "",
        hwxxmc: "",
      },
      detaile: {},
      tableData: [
        {
          time: "2016-05-02 15:30:56",
          name: "王小虎",
          phone: "15514597886",
          address: "上海市普陀区金沙江路 1518 弄",
          id: 1,
        },
        {
          time: "2016-05-04 15:30:56",
          name: "王小虎",
          phone: "15514597886",
          address: "上海市普陀区金沙江路 1517 弄",
          id: 2,
        },
        {
          time: "2016-05-01 15:30:56",
          name: "王",
          phone: "15514597886",
          address: "上海市普陀区金沙江路 1519 弄",
          id: 3,
        },
        {
          time: "2016-05-03 15:30:56",
          name: "王",
          phone: "15514597886",
          address: "上海市普陀区金沙江路 1516 弄",
          id: 4,
        },
        {
          time: "2016-05-02 15:30:56",
          name: "王",
          phone: "15514597886",
          address: "上海市普陀区金沙江路 1518 弄",
          id: 5,
        },
        {
          time: "2016-05-04 15:30:56",
          name: "王",
          phone: "15514597886",
          address: "上海市普陀区金沙江路 1517 弄",
          id: 6,
        },
        {
          time: "2016-05-01 15:30:56",
          name: "王",
          phone: "15514597886",
          address: "上海市普陀区金沙江路 1519 弄",
          id: 7,
        },
        {
          time: "2016-05-03 15:30:56",
          name: "王小虎",
          phone: "15514597886",
          address: "上海市普陀区金沙江路 1516 弄",
          id: 8,
        },
        {
          time: "2016-05-02 15:30:56",
          name: "王小虎",
          phone: "15514597886",
          address: "上海市普陀区金沙江路 1518 弄",
          id: 9,
        },
        {
          time: "2016-05-04 15:30:56",
          name: "王小虎",
          phone: "15514597886",
          address: "上海市普陀区金沙江路 1517 弄",
          id: 10,
        },
        {
          time: "2016-05-01 15:30:56",
          name: "王小虎",
          phone: "15514597886",
          address: "上海市普陀区金沙江路 1519 弄",
          id: 11,
        },
        {
          time: "2016-05-03 15:30:56",
          name: "王小虎",
          phone: "15514597886",
          address: "上海市普陀区金沙江路 1516 弄",
          id: 12,
        },
        {
          time: "2016-05-02 15:30:56",
          name: "王小虎",
          phone: "15514597886",
          address: "上海市普陀区金沙江路 1518 弄",
          id: 13,
        },
        {
          time: "2016-05-04 15:30:56",
          name: "王小虎",
          phone: "15514597886",
          address: "上海市普陀区金沙江路 1517 弄",
          id: 14,
        },
        {
          time: "2016-05-01 15:30:56",
          name: "王小虎",
          phone: "15514597886",
          address: "上海市普陀区金沙江路 1519 弄",
          id: 15,
        },
        {
          time: "2016-05-03 15:30:56",
          name: "王小虎",
          phone: "15514597886",
          address: "上海市普陀区金沙江路 1516 弄",
          id: 16,
        },
      ],
      initTableData: [
        {
          time: "2016-05-02 15:30:56",
          name: "王小虎",
          phone: "15514597886",
          address: "上海市普陀区金沙江路 1518 弄",
          id: 1,
        },
        {
          time: "2016-05-04 15:30:56",
          name: "王小虎",
          phone: "15514597886",
          address: "上海市普陀区金沙江路 1517 弄",
          id: 2,
        },
        {
          time: "2016-05-01 15:30:56",
          name: "王",
          phone: "15514597886",
          address: "上海市普陀区金沙江路 1519 弄",
          id: 3,
        },
        {
          time: "2016-05-03 15:30:56",
          name: "王",
          phone: "15514597886",
          address: "上海市普陀区金沙江路 1516 弄",
          id: 4,
        },
        {
          time: "2016-05-02 15:30:56",
          name: "王",
          phone: "15514597886",
          address: "上海市普陀区金沙江路 1518 弄",
          id: 5,
        },
        {
          time: "2016-05-04 15:30:56",
          name: "王",
          phone: "15514597886",
          address: "上海市普陀区金沙江路 1517 弄",
          id: 6,
        },
        {
          time: "2016-05-01 15:30:56",
          name: "王",
          phone: "15514597886",
          address: "上海市普陀区金沙江路 1519 弄",
          id: 7,
        },
        {
          time: "2016-05-03 15:30:56",
          name: "王小虎",
          phone: "15514597886",
          address: "上海市普陀区金沙江路 1516 弄",
          id: 8,
        },
        {
          time: "2016-05-02 15:30:56",
          name: "王小虎",
          phone: "15514597886",
          address: "上海市普陀区金沙江路 1518 弄",
          id: 9,
        },
        {
          time: "2016-05-04 15:30:56",
          name: "王小虎",
          phone: "15514597886",
          address: "上海市普陀区金沙江路 1517 弄",
          id: 10,
        },
        {
          time: "2016-05-01 15:30:56",
          name: "王小虎",
          phone: "15514597886",
          address: "上海市普陀区金沙江路 1519 弄",
          id: 11,
        },
        {
          time: "2016-05-03 15:30:56",
          name: "王小虎",
          phone: "15514597886",
          address: "上海市普陀区金沙江路 1516 弄",
          id: 12,
        },
        {
          time: "2016-05-02 15:30:56",
          name: "王小虎",
          phone: "15514597886",
          address: "上海市普陀区金沙江路 1518 弄",
          id: 13,
        },
        {
          time: "2016-05-04 15:30:56",
          name: "王小虎",
          phone: "15514597886",
          address: "上海市普陀区金沙江路 1517 弄",
          id: 14,
        },
        {
          time: "2016-05-01 15:30:56",
          name: "王小虎",
          phone: "15514597886",
          address: "上海市普陀区金沙江路 1519 弄",
          id: 15,
        },
        {
          time: "2016-05-03 15:30:56",
          name: "王小虎",
          phone: "15514597886",
          address: "上海市普陀区金沙江路 1516 弄",
          id: 16,
        },
      ],
      datalist: [],
      dialogVisible: false,
    };
  },
  methods: {
    handleClose(done) {
      this.$confirm("确认关闭？")
        .then(() => {
          done();
        })
        .catch(() => {});
    },
    submitForm(formData) {
      console.log(formData.name);
      this.tableData.forEach((e) => {
        // console.log(e);
        if (formData.name == e.name) {
          console.log(e);
          this.datalist.push(e);
        }
        // console.log(e.id);
      });
      this.tableData = this.datalist;
    },
    resetForm() {
      this.$refs["elForm"].resetFields();
      this.tableData = this.initTableData;
    },
    handleClick(row) {
      console.log(row);
      this.dialogVisible = true;
      this.detaile = row;
    },
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
      this.pageSize = val;
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
      this.currentPage = val;
    },
  },

  created() {},
  mounted() {},
};
</script>
<style scoped lang="scss">
#elform {
  /deep/.el-form-item__content {
    margin-left: 30px !important;
  }
}
.warn-top {
  // border: 1px red solid;
  padding: 10px;
  background-color: white;
  border-radius: 10px;
  width: 100%;
  height: auto;
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  align-content: center;
  justify-content: space-around;
  align-items: flex-start;
  box-sizing: border-box;
}
.warn-top {
  width: calc(100%);
}
// .auto-width {
//   width: "auto";
// }
.el-table {
  width: calc(100%);
}
.warn-content {
  margin-top: 20px;
  // border: 1px red solid;
  height: auto;
  background-color: white;
  border-radius: 10px;
  padding: 10px;
  box-sizing: border-box;
}
// /deep/ .has-gutter .thead {
//   border: 1px red solid !important;
// }
// /deep/.el-table .thead {
//   border: 1px red solid !important;
// }
.el-table .el-table__cell {
  padding: 12px 0;
  min-width: 0;
  box-sizing: border-box;
  text-overflow: ellipsis;
  vertical-align: middle;
  position: relative;
  text-align: center;
}
/deep/.el-table__header-wrapper {
  // border: 1px red solid !important;
  border-radius: 10px 10px 0 0;
}
/deep/.el-table {
  border: 1px #d7dbe3 solid;
  border-radius: 10px;
}
/deep/.has-gutter tr th {
  color: black;
  text-align: center;
  border: 1px d7dbe3 solid;
  background-color: #ecf5ff;
}
/deep/.is-leaf {
  border: 1px #d7dbe3 solid !important;
  border-top: none !important;
  border-left: none !important;
}
/deep/.el-table__cell {
  text-align: center !important;
}
// /deep/.el-table__row {
//   border: 1px red solid !important;
// }
/deep/.el-dialog {
  border-radius: 15px !important;
}
/deep/.el-dialog__header {
  text-align: left;
  font-weight: 600;
}
/deep/.el-dialog__body {
  padding: 20px !important;
}
/deep/.el-input__inner {
  border: 1px solid #d7dbe3 !important;
  background-color: white !important;
}
/deep/.el-range-editor.el-input__inner {
  position: relative !important;
  right: 47px !important;
}
/deep/.el-input--medium .el-input__inner {
  position: relative !important;
  right: 20px !important;
}
</style>
